cmake_minimum_required(VERSION 3.15)

project(Chatroom)

# QT env configuration
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt5 COMPONENTS 
    Core 
    Network
    REQUIRED
)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS 
    Core 
    Network
    REQUIRED
)
add_library(Chatroom STATIC
    src/chatclient.cpp
    include/chatclient.h
    include/ChatClient
    src/chatserver.cpp
    include/chatserver.h
    include/ChatServer
    include/chatdatapack.h
    src/chatdatapack.cpp
)
add_library(utils::Chatroom ALIAS Chatroom)

target_include_directories(Chatroom
    PUBLIC
    ${PROJECT_SOURCE_DIR}/include
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::Network
)
target_link_libraries(Chatroom
    PUBLIC
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::Network
    utils::QLogger
)

add_subdirectory(demo)